<template>
	<uni-transition :duration="260" :mode-class="['slide-bottom']" :styles="popupTransfromClass" :show="phoneShow">
		<view style="width: 100%;height: 2000rpx;">
		</view>
		<view
			style="box-sizing:border-box;width:100%;padding:100rpx 40rpx 250rpx;position: absolute;bottom:10rpx;background-color: rgba(96,96,96,0.5);">
			<button type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
				一键登录
			</button>
		</view>
	</uni-transition>
</template>
<script>
	import {
		getPhone,
		checkMobile
	} from '@/api/user.js'
	import uniTransition from '@/components/uni-transition/uni-transition.vue'
	export default {
		components: {
			uniTransition
		},
		data() {
			return {
				phoneShow: false,
				link: '',
				popupTransfromClass: {
					'position': 'fixed',
					'bottom': 0,
					'left': 0,
					'right': 0,
					'z-index': 1000,
					'background-color': 'transparent'
				},
			}
		},
		mounted() {
			let that = this
			console.log(11111)
			// this.$nextTick(function() {
			// 	this.$on('open', function(url) {
			// 		that.phoneShow = true
			// 		console.log(that.phoneShow)
			// 	});
			// })
		},

		methods: {
			getPhoneNumber(e) {
				console.log(e)
				const data = {
					jsCode: e.detail.code,
					iv: e.detail.iv,
					encryptedData: e.detail.encryptedData,
					sessionKey: uni.getStorageSync('session_key')
				}
				if (data.jsCode) {
					getPhone(data).then(res => {
						this.phoneShow = false
						uni.reLaunch({
							url: '/pages/index/index'
						})
					})
				}

			},
			open() {
				this.phoneShow = true
			},
			show() {
				checkMobile().then(res => {
					if (res.result) {
						this.phoneShow = true
					}
				})

			},
			close() {
				// this.phoneShow = true
				// console.log('close');
			}
		}
	}
</script>
<style lang="scss">

</style>
